/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef LAYERMAPCONFIG_H
#define LAYERMAPCONFIG_H

#include "IncFreeTrack.h"
#include "freetrackwidget.h"

class LayerMap;
class LayerMapCalibrate;
class FTLabel;
class FTPushButton;
class FTTabWidget;

class LayerMapConfig : public FreeTrackWidget
{
    Q_OBJECT
public:
    explicit LayerMapConfig(QWidget*, LayerMap*);

signals:
    // emit when a point is updated by the user
    void updatePoint(int,QPoint);

private slots:
    // Save slot (to update the layer)
    void updateMap();
    // The user has edited a point
    void updateUserPt1(QString);
    void updateUserPt2(QString);
    void updateUserPt3(QString);
    // Set lat/lon from GPS
    void updateCoord1();
    void updateCoord2();
    void updateCoord3();
    // import external (ozi MAP, Compe IMP, FreeTrack CAL) calibration files
    void importCalibration();

public slots:
    // Update point from calibrator
    void updateMapPt(int,QPoint);
    // clear cache
    void clearCache();
    // rebuild cache
    void rebuildCache();

private:
    // Widgets
    FTPushButton* save_button;
    FTPushButton* cancel_button;
    FTTabWidget* tabs;

    // tab setup
    QWidget* tab_setup;
    QLineEdit* title;
    FTLabel* title_label;
    QLineEdit* description;
    FTLabel* description_label;
    FTPushButton* import_ozical;
    FTPushButton* clear_cache;
    FTPushButton* rebuild_cache;

    // map tab
    LayerMapCalibrate* calibrator;

    // points tab
    QWidget* pointsTab;
    FTLabel* point1_label;
    FTLabel* point1_lat_label;
    QLineEdit* point1_lat;
    FTLabel* point1_lon_label;
    QLineEdit* point1_lon;
    FTLabel* point1_y_label;
    QLineEdit* point1_y;
    FTLabel* point1_x_label;
    QLineEdit* point1_x;
    FTPushButton* point1_getgps;

    FTLabel* point2_label;
    FTLabel* point2_lat_label;
    QLineEdit* point2_lat;
    FTLabel* point2_lon_label;
    QLineEdit* point2_lon;
    FTLabel* point2_y_label;
    QLineEdit* point2_y;
    FTLabel* point2_x_label;
    QLineEdit* point2_x;
    FTPushButton* point2_getgps;

    FTLabel* point3_label;
    FTLabel* point3_lat_label;
    QLineEdit* point3_lat;
    FTLabel* point3_lon_label;
    QLineEdit* point3_lon;
    FTLabel* point3_y_label;
    QLineEdit* point3_y;
    FTLabel* point3_x_label;
    QLineEdit* point3_x;
    FTPushButton* point3_getgps;

    LayerMap* layer_map;

    QLayout* createHorizontal();
    QLayout* createVertical();
};

#endif // LAYERMAPCONFIG_H
